{extend name="layout" /}
{block name="body"}
<div class="row">
    <div class="col-lg-12">
        <form>
            <div class="card">
                <div class="card-body">
                    <div class="form-group">
                        <label for="platename">板块名称</label>
                        <input type="hidden" class="form-control" id="id" value="{$plate.id}" disabled>
                        <input type="text" class="form-control" id="platename" value="{$plate.platename}"
                            placeholder="请输入板块名称">
                    </div>
                    <div class="form-group file-group">
                        <label for="plateicon">icon图标</label>
                        <div class="input-group">
                            <input type="text" id="plateicon" class="form-control file-value" name="plateicon"
                                value="{$plate.plateicon}" placeholder="icon图标">
                            <input type="file" accaccept=".png,.jpg,.jpeg,.bmp,.gif" style="display: none">
                            <div class="input-group-btn">
                                <button class="btn btn-default file-browser" type="button">上传图片</button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="appname">app名称</label>
                        <input type="text" class="form-control" id="appname" value="{$plate.appname}" disabled>
                    </div>
                    <div class="form-group">
                        <label for="admin">板块管理员</label>
                        <input type="text" class="form-control" id="admin" value="{$plate.admin}" placeholder="直接输入用户id即可,多个管理员请使用,号隔开">
                    </div>
                    <div class="form-group">
                        <label for="plateontent">板块描述</label>
                        <input type="text" class="form-control" id="plateontent" value="{$plate.plateontent}"
                            placeholder="板块描述">
                    </div>
                    <div class="form-group">
                        <label for="plategg">板块公告</label>
                        <input type="text" class="form-control" id="plategg" value="{$plate.plategg}"
                            placeholder="板块公告">
                    </div>
                    <div class="form-group">
                        <label for="plategg">发帖权限</label>
                        <select class="form-control" id="satus">
                            <option value="0" {if $plate["satus"] == 0}selected{/if}>只允许管理员发帖</option>
                            <option value="1" {if $plate["satus"] == 1}selected{/if}>全部用户</option>
                        </select>
                    </div>
                    <button type="button" onclick="updateplate()" class="btn btn-w-sm btn-primary mb-2">提交</button>
                    <button type="button" class="btn btn-default mb-2"
                        onclick="javascript:history.back(-1);return false;">返
                        回
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script>
    function updateplate() {
        var l = $('body').lyearloading({
            opacity: 0.2,
            spinnerSize: 'lg',
            spinnerText: '后台处理中，请稍后...',
            textColorClass: 'text-info',
            spinnerColorClass: 'text-info'
        });
        var id = $.trim($("#id").val());
        var platename = $.trim($("#platename").val());
        var plateicon = $.trim($("#plateicon").val());
        var admin = $.trim($("#admin").val());
        var plateontent = $.trim($("#plateontent").val());
        var plategg = $.trim($("#plategg").val());
        var satus = $.trim($("#satus").val());
        $.ajax({
            type: "POST",
            url: "{:url('bbs/editplate')}",
            data: {
                id: id,
                platename: platename,
                plateicon: plateicon,
                admin: admin,
                plateontent: plateontent,
                plategg: plategg,
                satus:satus
            },
            dataType: "json",
            success: function (data) {
                l.destroy();
                if (data.code == 1) {
                    notify.success(data.msg);
                    $("#exampleModal").modal('hide');
                    $('#tb_departments').bootstrapTable('refresh');
                } else {
                    notify.error(data.msg);
                    $("#exampleModal").modal('hide');
                }
            },
            error: function () {
                l.destroy();
                notify.error("系统错误");
            }
        })
    }
</script>
{/block}